# $Id$
# Maintainer: Ronald van Haren <ronald.archlinux.org>
# Contributor: damir <damir@archlinux.org>

pkgbase=liborigin2
pkgname=('liborigin2' 'liborigin2-docs')
pkgver=20110829
pkgrel=4
_tree_hh_ver=2.81
arch=('i686' 'x86_64')
url="http://soft.proindependent.com/liborigin2/"
license=('GPL3')
makedepends=('doxygen' 'qt4' 'boost')
replaces=('liborigin')
provides=('liborigin')
source=(http://sourceforge.net/projects/qtiplot.berlios/files/$pkgbase-20110829.zip
	http://tree.phi-sci.com/tree-$_tree_hh_ver.tar.gz
	liborigin.pro.archlinux)
sha1sums=('13851b17b21ec49375e4f5dfbd3ab4b9bf72f5be'
          '7776b67227c61be2d3f6ecbad3ab1386ee3abffd'
          '9bb73eccc031b3a9e7c061b8cdbaf3e20aa2669d')

prepare() {
	cd "${srcdir}/${pkgbase}"

	cp ../liborigin.pro.archlinux liborigin2.pro
	cp ../tree-$_tree_hh_ver/src/tree.hh . # get the header back like it was in previous releases
}

build() {
	cd "${srcdir}/${pkgbase}"

	qmake-qt4 liborigin2.pro QMAKESPEC=linux-g++
  	make QTDIR=/usr/ QMAKESPEC=linux-g++

	 # create documentation
        cd doc
        doxygen
}

package_liborigin2() {
        pkgdesc="A library for reading OriginLab OPJ project files"
        depends=('boost-libs')

        cd "${srcdir}/${pkgbase}"

  	INSTALL_ROOT="${pkgdir}" make install

        # install missing includes
        install -Dm644 tree.hh "${pkgdir}/usr/include/liborigin2/tree.hh"
        for i in *.h; do
          install -Dm644 ${i} "${pkgdir}/usr/include/liborigin2/${i}"
        done
}
package_liborigin2-docs() {
        pkgdesc="Documentation for liborigin2: a library for reading OriginLab OPJ project files"

        cd "${srcdir}/${pkgbase}/doc"
	install -d "${pkgdir}/usr/share/doc/${pkgbase}"
	cp -rf html/* "${pkgdir}/usr/share/doc/${pkgbase}"
	chmod 755 "${pkgdir}/usr/share/doc/liborigin2/images"
	chmod 644 "${pkgdir}/usr/share/doc/liborigin2/images/origin_import.png"
}
